package com.ffcs.crmd.tsp.core.netty.client;

import com.ffcs.crmd.tsp.api.dto.netty.RemotingCommand;
import com.ffcs.crmd.tsp.api.netty.INettyRemotingClient;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

/**
 * 
 * 功能说明:通信客户端消息处理类
 *
 * @author ZHONGFUHUA
 * 
 * @since 1.0.0-SNAPSHOT
 *
 */
public class NettyClientHandler extends SimpleChannelInboundHandler<RemotingCommand> {
    
    /**
     * 通信客户端
     */
    private INettyRemotingClient remotingClient;
    
    public NettyClientHandler(INettyRemotingClient remotingClient) {
        this.remotingClient = remotingClient;
    }
    
    /**
     * 
     * 功能说明:新消息到来时调用
     * 
     * @author zhongfuhua
     *
     * @Date 2016年1月16日
     *
     */
    @Override
    protected void channelRead0(ChannelHandlerContext ctx, RemotingCommand msg) throws Exception {
        remotingClient.processMessageReceived(ctx, msg);
    }
    
}
